<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>基本信息</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic }/ZeroClipboard/ZeroClipboard.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			if('${merchant.logoUrl }'==''){
				$("#photo").css("display", "none");
			}
			// 定义一个新的复制对象
			var clip = new ZeroClipboard($("a[id='clip_button']"), {
			  moviePath: "${ctxStatic }/ZeroClipboard/ZeroClipboard.swf"
			} );
			
			// 复制内容到剪贴板成功后的操作
			clip.on( 'complete', function(client, args) {
			   alert("复制成功，请到剪贴板粘帖！");
			} );
			
			// 定义一个新的复制对象
			var clip2 = new ZeroClipboard($("a[id='clip_button2']"), {
			  moviePath: "${ctxStatic }/ZeroClipboard/ZeroClipboard.swf"
			} );
			
			// 复制内容到剪贴板成功后的操作
			clip2.on( 'complete', function(client, args) {
			   alert("复制成功，请到剪贴板粘帖！");
			} );
			
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					/*
					if($("#logoUrl").val()==""){
						showJBoxMess("请上传商户封面.","error");
						return;
					}*/
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
		});
		
		function showPhoto(path){
			$("#logoUrl").val(path);
			$("#photo").css("display", "block");
			var imageSrc = '${ctx}/download?filePath='+path;
			$("#photo").attr("src", imageSrc);
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ivm/merchant/info">基本信息</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="merchant" action="${ctx}/ivm/merchant/info" method="post" class="form-horizontal">
		<tags:message content="${message}"/>
		<c:if test="${merchant.id==null || merchant.id==''}">
		<form:hidden path="id"/>
		</c:if>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>商户名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group display-none">
			<label class="control-label">副标题:</label>
			<div class="controls">
				<form:input path="assisTitle" htmlEscape="false" maxlength="200" cssStyle="width: 450px;" class="input-xxlarge measure-input valid"/>
			</div>
		</div>
		<div class="control-group display-none">
			<label class="control-label"><span class="color-red font-size20">*</span>商店封面:</label>
			<div class="controls">
				<form:hidden path="logoUrl" />
				<div class="photo">
					<c:if test="${merchant.id!=null && merchant.id!=''}">
						<img id="photo" src="${ctx}/download?filePath=${merchant.logoUrl }" style="width:149px; height:84px;" />
					</c:if>
					<c:if test="${merchant.id==null || merchant.id==''}">
						<img id="photo" src="" style="width:149px; height:84px;" />
					</c:if>
				</div>
				<a href="javascript:" class="btn" id="photoUpload">上传图片</a>
			</div>
		</div>
		<c:if test="${merchant.id!=null && merchant.id!=''}">
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>商户编号:</label>
			<div class="controls">
				<form:input path="id" readonly="true" title="${merchant.id}" style="width: 400px;"/>
				<a href="javascript:" class="btn" id="clip_button2" data-clipboard-target="id">复制</a>
			</div>
		</div>
		</c:if>
		<c:if test="${merchant.id!=null}">
		<div class="control-group display-none">
			<label class="control-label"><span class="color-red font-size20">*</span>商店链接:</label>
			<div class="controls">
				<form:input path="shopUrl" readonly="true" htmlEscape="false" maxlength="200" cssStyle="width: 400px;"  class="required" title="${merchant.shopUrl}"/>
				<a href="javascript:" class="btn" id="clip_button" data-clipboard-target="shopUrl">复制</a>
			</div>
		</div>
		</c:if>
		<div class="control-group display-none">
			<label class="control-label">是否开放:</label>
			<div class="controls">
				<form:radiobuttons path="openState" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required" />
			</div>
		</div>
		<div class="control-group display-none">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge"/>
			</div>
		</div>
		<div class="control-group display-none">
			<label class="control-label">账户信息:</label>
			<div class="controls">
				<ol class="articleSelectList">
					<li>已清算金额：0.0元&nbsp;&nbsp;<a href="javascript:" class="btn">明细</a></li>
					<li>未清算金额：0.0元&nbsp;&nbsp;<a href="javascript:" class="btn">明细</a></li>
				</ol>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ivm:merchant:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
